ActionController::Routing::Routes.draw do |map|
  map.bbs   '/bbs/*path',   :controller => 'intro', :action => 'bbs'
  map.home  '', :controller => 'intro', :action => 'index'
  map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate'
  map.help  '/help',    :controller => 'intro', :action => 'help'     
  map.about '/about',   :controller => 'intro', :action => 'about'
  map.terms '/terms',   :controller => 'intro', :action => 'terms'
  map.faq   '/faq',     :controller => 'intro', :action => 'faq'
  map.admin '/admin',   :controller => '/admin/general', :action => 'index'
  
  map.search '/search', :controller =>'searchers', :action => 'search'
  map.search '/find_local', :controller =>'searchers', :action => 'find_local'
  
  map.resources :users, :member => {:changepassword => :get, 
                                    :updatepassword => :put,
                                    :confirmed_schools => :get,
                                    :unconfirmed_schools => :get,
                                    :add => :post,
                                    :remove => :delete,
                                    :who_add_me => :get,
                                    :neighbors => :get,
                                    :published_events => :get,
                                    :change_avatar => :get,
                                    :update_avatar => :put
                                    }
  map.resource :session, :controller => 'sessions'
  
  map.with_options :controller => 'users' do |user|
    user.signup 'signup', :action => 'new'
    user.setting 'setting', :action => 'edit'
    user.changepassword 'setting/changepassword', :action => 'changepassword'
    user.change_avatar 'setting/avatar', :action => 'change_avatar'
  end
  
  map.with_options :controller => 'sessions' do |session|
    session.login 'login', :action => 'new'
    session.logout 'logout', :action => 'destroy'
  end
  
  map.resources :schools, :collection => {:unconfirmed  => :get,
                                          :confirmed    => :get,
                                          :search       => :get,
                                          :all_comments => :get,
                                          :requirements => :get,
                                          :new_camp     => :get,
                                          :new_board    => :get,
                                          :archives     => :get
                                          },
                          :member => {:validate => :put,
                                      :visit => :put} do |school|
    school.resources :comments, :controller  => "school_comments",
                                :path_prefix => "/schools/:school_id",
                                :name_prefix => "school_"
    school.resources :students, :path_prefix => "/schools/:school_id"
    school.resource  :group,    :controller  => "school_service_groups",
                                :path_prefix => "/schools/:school_id",
                                :name_prefix => "school_service_"
  end
  
  map.connect "/schools/date/:year/:month/:day", :controller => "schools",  
  :action => "show_date", :requirment => {:year => /(19|20)\d\d/,             
                                          :month => /[01]?\d/,                
                                          :day => /[0-3]?\d/ },                      
                          :month => nil, :day => nil                         
  
  map.resources :photos, 
                :member => {:share_event => :get,
                            :push_event => :post,
                            :share_school => :get,
                            :push_school => :post},
                :collection => {:multiup => :get,
                                :multi_create => :post,
                                :medit => :get,
                                :mupdate => :put} do |photo|
    photo.resources :comments, :controller => "photo_comments",
                              :path_prefix => "/photos/:photo_id",
                              :name_prefix => "photo_"
  end
  
  map.resources :events, :member => {:new_pic => :get,
                                     :create_pic => :post,
                                     :join => :put,
                                     :quit => :put,
                                     :choice_school => :get,
                                     :add_school => :put,
                                     :latest_comments => :get},
                         :collection => {:category => :get,
                                         :all => :get} do |event|
    event.resources :comments, :controller => "event_comments", 
                               :path_prefix => "/events/:event_id",
                               :name_prefix => "event_"
                               
  end
  
  map.resources :groups, :member => {:join => :put, 
                                     :quit => :delete,
                                     :invite_moderator => :get,
                                     :add_moderator => :put,
                                     :hidden => :put,
                                     :edit_position => :get,
                                     :update_position => :put}  do |group|
    group.resources :topics, :path_prefix => "/groups/:group_id" do |topic|
      topic.resources :posts, :path_prefix => "/groups/:group_id/topics/:topic_id"
    end
  end
  
  map.resources :messages, :member => {:reply => :get},
                           :collection => {:outbox => :get,
                                           :destroy_all => :delete}
                                           
  map.resources :books
  map.resources :areas
  # The priority is based upon order of creation: first created -> highest priority.
  
  # Sample of regular route:
  # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # You can have the root of your site routed by hooking up '' 
  # -- just remember to delete public/index.html.
  # map.connect '', :controller => "welcome"
  map.dizhen '/dizhen', :controller => 'dizhen/general', :action => 'index'
  # Allow downloading Web Service WSDL as a file with an extension
  # instead of a file named 'wsdl'
  map.connect ':controller/service.wsdl', :action => 'wsdl'

  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:id.:format'
  map.connect ':controller/:action/:id'
end
